<script type="text/javascript" src="/js/jquery.validate.js"></script>

<section class="grid_12" style="width: 60%;margin-left: 20%;">
	<div class="block-border" style="margin-bottom: 20px;">
	<form class="block-content form" id="edit_form" method="post" action="">
	
		<h1>個人情報変更</h1>
	
		<fieldset><legend>ユーザ情報</legend>
				<?php if ($this->msg != null) {?>
					<p class="message success no-margin"><?php
        					echo $this->msg;
        			?></p>
        		<?php }?>
				
				<p class="inline-label"><label for="name">名前</label>
					<?php echo $this->formText("name",$this->name);?>
				</p>

				<p class="inline-label"><label for="email">メールアドレス</label>
					<?php echo $this->formText("email", $this->email);?>
				</p>

				<p class="inline-label"><label for="phone">電話番号</label>
					<?php echo $this->formText("phone", $this->phone);?>
				</p>
				
				<p class="inline-label">
					<label for="address">アドレス</label>
					<?php echo $this->formTextarea("address", $this->address, array('rows'=>3, 'cols'=>50));?>
				</p>
				<?php echo $this->formHidden("callback", $this->callback);?>
		</fieldset>

<fieldset class="grey-bg no-margin">
<p>
<button type="submit">変更</button>
<button type="button" id="cancel_btn">キャンセル</button>
</p>
</fieldset>

</form>
</div>
</section>

<!-- Table script -->
<script type="text/javascript">
$(document).ready(function(){
	$("#cancel_btn").click(function(){
		if($("#callback").val() == "admin")
			window.location = "/admin";
		else
			window.location = "/user";
	});
	
	$("#edit_form").validate({
 		rules: {
 			name: {
 				required: true
 			},
 			email: {
 	 			required: true,
 	 			email: true
 			},
			phone: {
				required: true,
				number: true
			}
		},
		messages: {
			name: "このフィールドは必須です。",
			email: {
				required: "このフィールドは必須です。",
				email: "有効なメールアドレスを入力してください。"//,
			},
			phone: {
				required: "このフィールドは必須です。",
				number: "有効な番号を入力してください。"
			}
		}
	});
});
</script>